home *** CD-ROM | disk | FTP | other *** search
/ Suzy B Software 2 / Suzy B Software CD-ROM 2 (1994).iso / extras / programm / detaz / detaz.c < prev    next >
C/C++ Source or Header  |  1995-04-27  |  1KB  |  69 lines

  1. #include <stdio.h>
  2. #include <mintbind.h>
  3. #include <stdlib.h>
  4. #include <dos.h>
  5. #include <cookie.h>
  6.  
  7. long execle(char *,...);
  8.  
  9. int    main(int ac,char **av)
  10. {
  11.     char    *cmd = "-xf",*p;
  12.     char    prg1[FMSIZE];
  13.     char    prg2[FMSIZE];
  14.     short    fds[2];
  15.     long        pid,exit_status;
  16.  
  17.     if(getcookie('MiNT',NULL)==0)
  18.     {
  19.         fprintf(stderr,"detaz: needs MINT!!\n");
  20.         exit(EXIT_FAILURE);
  21.     }
  22.  
  23.     if(ac<2 || ac>3)
  24.     {
  25.         fprintf(stderr,"detaz [-l] infile\n");
  26.         exit(EXIT_FAILURE);
  27.     }
  28.     p = av[1];
  29.     if(*p=='-')
  30.     {
  31.         ++p;
  32.         if(*p=='l'||*p=='L')
  33.         {
  34.             cmd = "-tf";
  35.             ++av;
  36.             --ac;
  37.         }
  38.     }
  39.     if(getpfe(prg1,"gzip.ttp"))
  40.     {
  41.         fprintf(stderr,"detaz:can't find gzip\n");
  42.         exit(EXIT_FAILURE);
  43.     }
  44.     if(getpfe(prg2,"tar.ttp"))
  45.     {
  46.         fprintf(stderr,"detaz:can't find tar\n");
  47.         exit(EXIT_FAILURE);
  48.     }
  49.     if(Fpipe(fds)<0)
  50.     {
  51.         fprintf(stderr,"detaz can't pipe!!\n");
  52.         exit(EXIT_FAILURE);
  53.     }
  54.     if(Pfork()==0)
  55.     {
  56.         Fforce(1,fds[1]);
  57.         execle(prg1,"-dc",av[1],NULL);
  58.     }
  59.     if((pid=Pfork())==0)
  60.     {
  61.         Fforce(0,fds[0]);
  62.         execle(prg2,"xf","-",NULL);
  63.     }
  64.     
  65.     Pwaitpid(pid,0,&exit_status);
  66.     return 0;
  67. }
  68.  
  69.